﻿using System.Text;
using System.Security.Cryptography;

namespace SnippetBox.Core.Common.Security {
    public static class Hash {

        private const string SALT = @"dVn39Al3jbvA)vn309=io3vbslA9n3fgba098((38&/42Q-";

        public static string Make(string input) {
            MD5 hasher = MD5.Create();
            byte[] data = hasher.ComputeHash(Encoding.Unicode.GetBytes(input));
            StringBuilder hValue = new StringBuilder();

            for (int index = 0; index < data.Length; index++)
                hValue.Append(data[index].ToString("x2"));
			
            data = hasher.ComputeHash(Encoding.Unicode.GetBytes(SALT + hValue));
            hValue = new StringBuilder();
			
            for (int index = 0; index < data.Length; index++)
                hValue.Append(data[index].ToString("x2"));
		
            return hValue.ToString();
        }
    }
}